<form id="findCustomerfm" method="post" novalidate>
        <div class="ftitle">查询客户</div>
            <div class="fitem">
                <p>可以通过姓名,手机,QQ,Email,微信等信息查询</p>
            </div> 
           <div class="fitem">
                <input name="search">
            </div>                                                   
        </form>
    <div id="customer-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="javascript:findCustomerJs.invokeSearch()">查询</a>
    </div>
    
    <table id="findCustomerList"></table>
<script type="text/javascript">
(function(findCustomerJs, $, undefined ) {  	
	$('#findCustomerList').datagrid({
		width:550,
		height:200,
		fitColumns:true,
		singleSelect:true,
		url:null,
	    columns:[[
	             	{title:'照片',field:'pic',width:80},
	             	{title:'姓名',field:'name',width:80},
	             	{title:'电话',field:'cell',width:80},
	             	{title:'QQ',field:'qq',width:50},
	             	{title:'微信',field:'weixin',width:50},
	             	{title:'email',field:'email',width:80},
	             ]],
		pagination:false,
		onDblClickRow :selectRow
	});
	function selectRow()
	{
		var row = $('#findCustomerList').datagrid('getSelected');
        if (row){
        	customerActionJs.CustomerActionCompelete(row);
        }else
        	{
        		$.messager.alert("Error","请选择一条记录");
        	}
	}
	findCustomerJs.invokeSearch = function(){
		var value = $("#findCustomerfm input[name='search']").val();
		if(value == "")
		{
			alert("请输入查询条件");
		}else
		{
			var str = "value="+value;
			$('#findCustomerList').datagrid("loading");
    		$.ajax({
                type: "post",
                url: "dispatch/customer/search",
                dataType:"json",
                data: str,
                cache: false,
                success: function (result) {
                	$('#findCustomerList').datagrid("loaded");
                	fillSearchResult(result);
                }
			});
		}
	}
	function fillSearchResult(result)
	{
    	var res = result.result;
        if(res == "SUCCESS")
        {
        	var payload = jQuery.parseJSON(result.payload.value);
        	$('#findCustomerList').datagrid('loadData',payload);
        	if(payload == '')$.messager.alert("Error",'没有搜索到');
        }else if(res == "COMPONENT_ERROR")
        {
        	$.messager.alert("Error",result.payload.value);
        }else
        {
        	$.messager.alert("Error",result.result);
        }
	}
}( window.findCustomerJs = window.findCustomerJs || {}, jQuery ));

	</script>